refactor: drop json5 dep, handle non-finite floats in socket parse fallback#6339
refactor: drop json5 dep, handle non-finite floats in socket parse fallback#6339FarhanAliRaza wants to merge 2 commits intoreflex-dev:mainfrom
Conversation
…llback Happy path uses native JSON.parse; the catch rewrites Python"s bare Infinity/-Infinity/NaN tokens outside string literals before retrying, so only payloads that actually contain specials pay the extra cost. NaN has no JSON literal and becomes null (matches JSON.stringify).
Greptile SummaryThis PR removes the
Confidence Score: 5/5Safe to merge; all findings are P2 style/documentation suggestions with no runtime correctness issues. The regex implementation correctly handles Python's non-finite float tokens and the string-literal-first alternation prevents false positives inside quoted values. Removing json5 is a clean, well-scoped change. Both open findings are P2: one asks for word-boundary guards that are not required for real payloads, and one notes the intentional NaN→null behavior change lacks a deprecation/changelog entry. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Socket.io packet received (str)"] --> B["JSON.parse(str)"]
B -->|success| C["Return parsed object"]
B -->|throws| D["rewriteBareNonFiniteFloats(str)"]
D --> E["Regex: match string literals first\n(pass through unchanged)"]
E --> F["Replace bare Infinity → 1e999\n-Infinity → -1e999\nNaN → null"]
F --> G["JSON.parse(rewritten str)"]
G -->|success| H["Return parsed object\n(NaN becomes null, ±Inf preserved)"]
G -->|throws| I["Return false\n(malformed payload)"]
Reviews (1): Last reviewed commit: "refactor: drop json5 dep, handle non-fin..." | Re-trigger Greptile |
…o null Swap bare NaN for a sentinel string before JSON.parse and revive it back to a real NaN so Python-side float(nan) round-trips to the frontend.
…
Happy path uses native JSON.parse; the catch rewrites Python"s bare Infinity/-Infinity/NaN tokens outside string literals before retrying, so only payloads that actually contain specials pay the extra cost. NaN has no JSON literal and becomes null (matches JSON.stringify).
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
claoses #5820
Will also help with the lighthouse score, I think.